#pragma once

//NOTE: Only one init_seg directive can appear in a single source file. Otherwise, the compiler generates "error C2356: initialization segment must not change during translation unit." 
// if you want declare at normal segment then declare above "#pragma init_seg(compiler)"
//#pragma init_seg(compiler)

//OptionFlag. Option Is one or combination of options 
#ifndef _CRASHHANDLER_H
	#define GSTSO_PARAMS    0x01
	#define GSTSO_MODULE    0x02
	#define GSTSO_SYMBOL    0x04
	#define GSTSO_SRCLINE   0x08
#endif


namespace _FOGGE_
{
	namespace _UTIL_
	{
		class ExceptionHandler
		{
		public:
			ExceptionHandler(void);
			~ExceptionHandler(void);

			void ShowFaultReason(bool flag);
			void EnableStackTrace(bool flag);
			void ShowRegister(bool flag);
			void SetLetItCrash(bool flag);
			void SetOption(DWORD option);

			LONG ExcepCallBack ( EXCEPTION_POINTERS * pExPtrs );
	
		protected:
			bool  m_bGetFaultReason;
			bool  m_bGetStackTraceString;
			bool  m_bShowRegs;
			bool  m_bLetItCrash;
			DWORD  m_dwOpts;

			
		};

		static ExceptionHandler g_ExceptionHandler;
	}
}

#define ExceptionHandler_BEGIN \
	__try\
	{
		
#define ExceptionHandler_END \
	} \
	__except(_FOGGE_::_UTIL_::g_ExceptionHandler.ExcepCallBack(GetExceptionInformation()))\
    {\
    }
